﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Xml;

namespace ArtistsExtractor
{
    class ArtistsExtractor
    {
        static void Main()
        {
            const string SourceXML = @"..\..\..\catalog.xml";

            Hashtable artists = new Hashtable();

            XmlDocument doc = new XmlDocument();
            doc.Load(SourceXML);

            XmlNode rootNode = doc.DocumentElement;

            foreach (XmlNode node in rootNode.ChildNodes)
            {
                string artist = node["artist"].InnerText;
                if (artists.ContainsKey(artist))
                {
                    int currentCount = (int)artists[artist];
                    currentCount++;
                    artists[artist] = currentCount;
                }
                else
                {
                    artists.Add(artist, 1);
                }
            }

            Console.WriteLine("Number of albums in the catalog:");
            foreach (DictionaryEntry item in artists)
            {
                Console.WriteLine("{0}: {1}", item.Key, item.Value);
            }
        }
    }
}
